﻿
var type = getCookie('jiangjin').split("&")[3].split("=")[1];
if (type == '07332506fa00992798c91411c89023a8') {
    $("#exampleAccordion>li:nth-child(7) a").removeClass("collapsed");
    $("#exampleAccordion>li:nth-child(7) ul").addClass("show");
    $("#exampleAccordion>li:nth-child(7) ul>li:nth-child(3)").addClass("active");
}else{
    $("#exampleAccordion>li:nth-child(4) a").removeClass("collapsed");
    $("#exampleAccordion>li:nth-child(4) ul").addClass("show");
    $("#exampleAccordion>li:nth-child(4) ul>li:nth-child(1)").addClass("active");
}
//申请开通账号
function SetUpAccount() {
    var html = "";
    html += '<div class="card-body">';
    html += '<form class="Regist">';
    html += '<div class="form-group">';
    html += '<div class="form-row">';
    html += '<div class="col-md-6">';
	html += '<label for="expSuperior">安置人</label>';
    html += '<input class="form-control" id="expSuperior" type="text" name="expSuperior" placeholder="请输入编号">';
    html += '</div>';
    html += '<div class="col-md-6">';
	html += '<label for="emoneySuperior">推荐人</label>';
    html += '<input class="form-control" id="emoneySuperior" type="text" name="emoneySuperior" placeholder="请输入编号">';
    html += '</div>';
    html += '</div>';
    html += '</div>';
    html += '<div class="form-group">';
    html += '<div class="form-row">';
    html += '<div class="col-md-6">';
	html += '<label for="userName">用户名称</label>';
    html += '<input class="form-control" id="userName" type="text" name="userName" placeholder="请输入用户名称">';
    html += '</div>';
    html += '<div class="col-md-6">';
    html += '<label for="emoneySuperior">所属公司或服务中心</label>';
    html += '<input class="form-control" id="content" type="text" name="content" placeholder="请输入公司或服务中心编号">';
    html += '</div>';
    html += '</div>';
    html += '</div>';
    html += '<a class="btn btn-primary btn-block" href="javascript:void(0)" onclick="sub()">提交</a>';
    html += '</form>';
    html += '</div>';
    html += '</div>';
    layer.open({
        type: 1,
        shadeClose: true,
        title: '填写申请人信息',
        area: ['600px', "350px"], //宽高
        content: html,
    });

    $(".Regist").bootstrapValidator({
        message: '无效的值',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh',
        },
        fields: {
            expSuperior: {
                message: '无效值',
                validators: {
                    regexp: {
						regexp: /^[A-Z0-9]*$/,
						message: '请检查后再次尝试'
                    }
                }
            },
            emoneySuperior: {
                message: '无效值',
                validators: {
                    regexp: {
						regexp: /^[A-Z0-9]*$/,
						message: '请检查后再次尝试'
                    }
                }
            },
            userName: {
                message: '无效值',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    }
                }
            },
            content: {
                message: '无效值',
                validators: {
                    regexp: {
						regexp: /^[A-Z0-9]*$/,
						message: '请检查后再次尝试'
                    }
                }
            }
        }
    })


}
//提交
function sub() {
    var bootstrapValidator = $(".Regist").data('bootstrapValidator');
    bootstrapValidator.validate();
    if (bootstrapValidator.isValid()) {
        var option = {
            type: 'post',
            url: '/Member/SubmintMsg',
            data: { name: $("#userName").val(), mUP: $("#emoneySuperior").val(), eUP: $("#expSuperior").val(), content: $("#content").val() },
            callback: SetMode
        }
        swGather.swAjax(option)
    }
}
function SetMode(data) {
    layer.msg(data.Msg);
    layer.closeAll('page');
}
function withdraw() {
    layer.prompt({ title: '输入你要提现的金额', formType: 0 }, function (text, index) {
        var rex = /^[0-9]*$/;
        if (!rex.test(text)) {
            layer.msg("请输入数字");
        } else if (Number($("#Money span").text()) < Number(text)) {
            layer.msg("余额不足");
		} else if (Number($("#Money span").text()) < 50){
			layer.msg("每次提现金额需大于50元");
		} else {
            $.post("/Member/Withdraw", { money: text }, function (data) {
                if (data.Code == "OK") {
                    layer.msg(data.Msg);
                } else {
                    layer.msg(data.Msg);
                }
            })
        }
        layer.close(index);
    });
}